package com.TeamJigsaw.DanteTrail.Views;

import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.event.ActionListener;

import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JPanel;

import net.miginfocom.swing.MigLayout;

import com.TeamJigsaw.DanteTrail.Views.Interfaces.MapViewInterface;

public class MapView extends JPanel implements MapViewInterface{
	
	private String htmlStart, htmlEnd;
	private JLabel lblPreviousCheckpoint, lblDistanceToNext,lblNextCheckpoint, lblTotalDistanceTravelled,
	lblDistanceUntilEnd, lblCurrentDate;
	private JLabel prevCheck;
	private JLabel disToNext;
	private JLabel nextCheck;
	private JLabel totalDis;
	private JLabel disLeft;
	private JLabel currDate;
	private JButton btnReturn;
	private MapScreenDisplay mapScreenDisplay;
	private MapScreenDisplay mapScreenDisplay_1;
	private JPanel panel;
	
	public MapView()
	{
		setSize(new Dimension(700,700));
		setLayout(new MigLayout("", "[100:100:100][250:250:250,grow][40:40:40][210:210:210][][]", "[][300:300:300,grow][30:30:30][][30:30:30][][30:30:30][][30:30:30][][30:30:30][][30:30:30][][][][]"));
		
		
		
		htmlStart = "<html><font size=\"4\" color=\"#FFFFFF\"><b>";
		htmlEnd = "</b></font></html>";
		initialize();
	}
	
	public void initialize()
	{
		
				
		lblPreviousCheckpoint = new JLabel(htmlStart+"Previous Checkpoint:"+htmlEnd);
		add(lblPreviousCheckpoint, "cell 1 3");
		
		prevCheck = new JLabel(htmlStart+"New label"+htmlEnd);
		add(prevCheck, "cell 3 3");
		
		lblDistanceToNext = new JLabel(htmlStart+"Distance To Next Checkpoint:"+htmlEnd);
		add(lblDistanceToNext, "cell 1 5");
		
		disToNext = new JLabel(htmlStart+"New label"+htmlEnd);
		add(disToNext, "cell 3 5");
		
		lblNextCheckpoint = new JLabel(htmlStart+"Next Checkpoint:"+htmlEnd);
		add(lblNextCheckpoint, "cell 1 7");
		
		nextCheck = new JLabel(htmlStart+"New label"+htmlEnd);
		add(nextCheck, "cell 3 7,alignx left,aligny top");
		
		lblTotalDistanceTravelled = new JLabel(htmlStart+"Total Distance Travelled:"+htmlEnd);
		add(lblTotalDistanceTravelled, "cell 1 9");
		
		totalDis = new JLabel(htmlStart+"New label"+htmlEnd);
		add(totalDis, "cell 3 9");
		
		lblDistanceUntilEnd = new JLabel(htmlStart+"Distance Until End:"+htmlEnd);
		add(lblDistanceUntilEnd, "cell 1 11");
		
		disLeft = new JLabel(htmlStart+"New label"+htmlEnd);
		add(disLeft, "cell 3 11");
		
		lblCurrentDate = new JLabel(htmlStart+"Current Date:"+htmlEnd);
		add(lblCurrentDate, "cell 1 13");
		
		currDate = new JLabel(htmlStart+"New label"+htmlEnd);
		add(currDate, "cell 3 13");
		
		btnReturn = new JButton("Return");
		add(btnReturn, "cell 4 15");
	}

	@Override
	public void setPrevCheckpoint(String check) {
		prevCheck.setText(htmlStart+check+htmlEnd);
		
	}

	@Override
	public void setNextCheckpoint(String check) {
		nextCheck.setText(htmlStart+check+htmlEnd);
		
	}

	@Override
	public void setDistanceTravelled(int dis) {
		totalDis.setText(htmlStart+dis+htmlEnd);
		
	}

	@Override
	public void setDistanceLeft(int dis) {
		disLeft.setText(htmlStart+dis+htmlEnd);
		
	}

	@Override
	public void setDistanceToNextCheckpoint(int dis) {
		disToNext.setText(htmlStart+dis+htmlEnd);
		
	}

	@Override
	public void setDate(String date) {
		currDate.setText(htmlStart+date+htmlEnd);
		
	}

	@Override
	public void setReturnListener(ActionListener listen) {
		btnReturn.addActionListener(listen);
		
	}
	
	@Override
	public void paintComponent(Graphics g) {
		ImageIcon img = new ImageIcon("resources\\stone_texture.png");
	    g.drawImage(img.getImage(), 0, 0, null);
	  }

	@Override
	public void setMapDisplay(MapScreenDisplay display) {
		mapScreenDisplay = display;
		
		add(mapScreenDisplay, "cell 1 1 3 1,grow");
		
	}
}
